load("//rs/tests:common.bzl", "COUNTER_CANISTER_RUNTIME_DEPS", "GRAFANA_RUNTIME_DEPS", "UNIVERSAL_VM_RUNTIME_DEPS")
load("//rs/tests:system_tests.bzl", "system_test", "system_test_nns")

package(default_visibility = ["//rs:system-tests-pkg"])

CERTIFICATE_ORCHESTRATOR_RUNTIME_DEPS = ["//rs/boundary_node/certificate_issuance/certificate_orchestrator:certificate_orchestrator"]

system_test_nns(
    name = "api_bn_integration_test",
    runtime_deps = GRAFANA_RUNTIME_DEPS,
    deps = [
        # Keep sorted.
        "//rs/tests/boundary_nodes/integration_test_common",
        "//rs/tests/boundary_nodes/utils",
        "//rs/tests/driver:ic-system-test-driver",
        "//rs/types/types",
        "@crate_index//:anyhow",
    ],
)

system_test_nns(
    name = "api_bn_update_workload_test",
    additional_colocate_tags = [
        "system_test_benchmark",
    ],
    colocated_test_driver_vm_required_host_features = ["performance"],
    colocated_test_driver_vm_resources = {
        "vcpus": 16,
    },
    enable_head_nns_variant = False,
    tags = [
        "colocate",
    ],
    test_timeout = "eternal",
    runtime_deps = GRAFANA_RUNTIME_DEPS + COUNTER_CANISTER_RUNTIME_DEPS,
    deps = [
        "//rs/tests/driver:ic-system-test-driver",
        "//rs/tests/networking/subnet_update_workload",
        "@crate_index//:anyhow",
    ],
)

system_test_nns(
    name = "certificate_orchestrator_test",
    env = {
        "CERTIFICATE_ORCHESTRATOR_WASM_PATH": "$(rootpath //rs/boundary_node/certificate_issuance/certificate_orchestrator:certificate_orchestrator)",
    },
    runtime_deps = UNIVERSAL_VM_RUNTIME_DEPS +
                   CERTIFICATE_ORCHESTRATOR_RUNTIME_DEPS,
    deps = [
        # Keep sorted.
        "//rs/boundary_node/certificate_issuance/certificate_orchestrator_interface",
        "//rs/registry/subnet_type",
        "//rs/tests/driver:ic-system-test-driver",
        "//rs/types/types",
        "@crate_index//:anyhow",
        "@crate_index//:candid",
        "@crate_index//:ic-agent",
        "@crate_index//:k256",
        "@crate_index//:rand",
        "@crate_index//:rand_chacha",
        "@crate_index//:slog",
        "@crate_index//:tokio",
    ],
)

system_test_nns(
    name = "salt_sharing_canister_test",
    env = {
        "SALT_SHARING_CANISTER_WASM_PATH": "$(rootpath //rs/boundary_node/salt_sharing:salt_sharing_canister)",
    },
    proc_macro_deps = [],
    runtime_deps = [
        "//rs/boundary_node/salt_sharing:salt_sharing_canister",
    ],
    deps = [
        # Keep sorted.
        "//rs/boundary_node/salt_sharing/api:salt_sharing_api",
        "//rs/nns/constants",
        "//rs/nns/test_utils",
        "//rs/registry/subnet_type",
        "//rs/rust_canisters/canister_test",
        "//rs/tests/boundary_nodes/utils",
        "//rs/tests/driver:ic-system-test-driver",
        "//rs/types/base_types",
        "//rs/types/types",
        "@crate_index//:anyhow",
        "@crate_index//:candid",
        "@crate_index//:ic-agent",
        "@crate_index//:slog",
        "@crate_index//:tokio",
        "@crate_index//:wat",
    ],
)

system_test_nns(
    name = "rate_limit_canister_test",
    env = {
        "RATE_LIMIT_CANISTER_WASM_PATH": "$(rootpath //rs/boundary_node/rate_limits:rate_limit_canister)",
    },
    proc_macro_deps = ["@crate_index//:async-trait"],
    tags = [
        "long_test",  # the P90 duration was over 5 minutes for the week starting on 2025-08-25.
    ],
    runtime_deps = [
        "//rs/boundary_node/rate_limits:rate_limit_canister",
    ],
    deps = [
        # Keep sorted.
        "//rs/boundary_node/rate_limits/api:rate_limits_api",
        "//rs/nns/constants",
        "//rs/nns/test_utils",
        "//rs/registry/subnet_type",
        "//rs/rust_canisters/canister_test",
        "//rs/tests/boundary_nodes/utils",
        "//rs/tests/driver:ic-system-test-driver",
        "//rs/types/base_types",
        "//rs/types/types",
        "@crate_index//:anyhow",
        "@crate_index//:candid",
        "@crate_index//:ic-agent",
        "@crate_index//:k256",
        "@crate_index//:rand",
        "@crate_index//:rand_chacha",
        "@crate_index//:regex",
        "@crate_index//:slog",
        "@crate_index//:tokio",
        "@crate_index//:wat",
    ],
)

system_test_nns(
    name = "api_bn_performance_test",
    colocated_test_driver_vm_required_host_features = ["performance"],
    colocated_test_driver_vm_resources = {
        "vcpus": 64,
        "memory_kibibytes": 512142680,
        "boot_image_minimal_size_gibibytes": 500,
    },
    tags = ["manual"],
    runtime_deps = GRAFANA_RUNTIME_DEPS + COUNTER_CANISTER_RUNTIME_DEPS,
    deps = [
        # Keep sorted.
        "//rs/tests/boundary_nodes/performance_test_common",
        "//rs/tests/boundary_nodes/utils",
        "//rs/tests/driver:ic-system-test-driver",
        "@crate_index//:anyhow",
    ],
)

system_test(
    name = "mainnet_bn_performance_test",
    colocated_test_driver_vm_required_host_features = ["performance"],
    colocated_test_driver_vm_resources = {
        "vcpus": 64,
        "memory_kibibytes": 512142680,
        "boot_image_minimal_size_gibibytes": 500,
    },
    env_inherit = ["BOUNDARY_NODE_IPV6"],
    tags = [
        "manual",
    ],
    runtime_deps = GRAFANA_RUNTIME_DEPS + COUNTER_CANISTER_RUNTIME_DEPS,
    deps = [
        # Keep sorted.
        "//rs/tests/boundary_nodes/performance_test_common",
        "//rs/tests/driver:ic-system-test-driver",
        "@crate_index//:anyhow",
    ],
)

system_test(
    name = "mainnet_bn_ic_gateway_performance_test",
    colocated_test_driver_vm_required_host_features = ["performance"],
    colocated_test_driver_vm_resources = {
        "vcpus": 64,
        "memory_kibibytes": 512142680,
        "boot_image_minimal_size_gibibytes": 500,
    },
    env_inherit = ["BOUNDARY_NODE_IPV6"],
    tags = [
        "manual",
    ],
    runtime_deps = GRAFANA_RUNTIME_DEPS + COUNTER_CANISTER_RUNTIME_DEPS,
    deps = [
        # Keep sorted.
        "//rs/tests/boundary_nodes/performance_test_common",
        "//rs/tests/driver:ic-system-test-driver",
        "@crate_index//:anyhow",
    ],
)

system_test_nns(
    name = "api_bn_decentralization_test",
    tags = [
        "long_test",  # since it takes longer than 5 minutes.
    ],
    runtime_deps = GRAFANA_RUNTIME_DEPS,
    deps = [
        # Keep sorted.
        "//rs/canister_client",
        "//rs/nervous_system/common/test_keys",
        "//rs/nns/common",
        "//rs/nns/constants",
        "//rs/nns/governance/api",
        "//rs/nns/test_utils",
        "//rs/registry/canister",
        "//rs/tests/boundary_nodes/utils",
        "//rs/tests/driver:ic-system-test-driver",
        "//rs/types/base_types",
        "//rs/types/types",
        "@crate_index//:anyhow",
        "@crate_index//:candid",
        "@crate_index//:ic-agent",
        "@crate_index//:itertools",
        "@crate_index//:k256",
        "@crate_index//:slog",
        "@crate_index//:tokio",
        "@crate_index//:wat",
    ],
)
